54
Beginner’s Guide to Code Algorithms
54
STEP 14 continued
For i = 1 To 9
For j = 1 To 9
putnumberpresent(i, j) = ““
Next j
Next i
For i = 1 To 9
ColumnCount = 0
putnumberpresent(1, i) = ““
lastcorner = ““
For j = 1 To 9
If sbox(j, i) = ““ Then
If findincantbelist(putnumber, j, i) = 0 Then
lastcorner = lastcorner & j
putnumberpresent(j, i) = lastcorner
ColumnCount = ColumnCount + 1
End If
End If
Next j
If ColumnCount = 2 Then
Else
putnumberpresent(1, i) = “*”
End If
Next i
:
:
STEP 15
The second step is to scan the putnumberpresent array to identify the other two corners.
Once identified, all cells in the same two rows that the corners are in get the
candidate number (putnumber) in each of their cantbelist (remember the array that
stores what the cell cannot be?) except for the corners of the rectangle.
:
:
For i = 1 To 9
For j = 1 To 9
If putnumberpresent(1, j) <> “*” And sbox(i, j) = ““ And
putnumberpresent(i, j) <> ““ Then
For k = j To 9
If putnumberpresent(i, k) = putnumberpresent(i, j) And k <> j And
Len(putnumberpresent(i, j)) = 2 And putnumberpresent(1, k) <>
“*” Then
‘column j,k and rows stored in putnumber are the rectangle
‘all cells in the rows of the rectangle except the corners,
‘should have putnumber in cantbelist
For kk = 1 To 9
If kk = j Or kk = k Then
Else
Call addtocantbelist(putnumber, Mid(putnumberpresent(i, j), 1,
1), kk)